﻿using DevExpress.XtraEditors;
using DevExpress.XtraRichEdit;
using DLL;
using NursingFormSystem.BLL;
using NursingFormSystem.Common;
using NursingFormSystem.Model;
using NursingFormSystem.Notice;
using SQLDLL;
using System;
using System.Data;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;

namespace NursingDocumentInfoSystem
{
    public partial class NusingEntryForm : XtraForm
    {
        #region 变量声明
        public string departID;
        public string departName;
        public string nurseID;
        public bool insert = true;
        public string ID;
        public static Random rd = new Random();　　//无参即为使用系统时钟为种子
        string patientId = "";
        #endregion

        #region 窗体加载
        public NusingEntryForm(string[] userParam, string[] patient)
        {
            InitializeComponent();
            patientId = patient[0];
            lab_PatientID.Text = patient[0];
            lab_VisitID.Text = patient[1];
            lab_Name.Text = patient[2];
            txtE_Signature.Text = userParam[1];
            departID = userParam[2];
            departName = userParam[3];
            nurseID = userParam[0];
            InitializationControlsData(groupControl1.Controls);
            insert = true;
        }
        public NusingEntryForm(string[] userParam, string[] patient, string id)
        {
            InitializeComponent();
            patientId = patient[0];
            lab_PatientID.Text = patient[0];
            lab_VisitID.Text = patient[1];
            lab_Name.Text = patient[2];
            txtE_Signature.Text = userParam[1];
            departID = userParam[2];
            departName = userParam[3];
            nurseID = userParam[0];
            if (string.IsNullOrEmpty(id) || id.Equals("-1"))  //新增
            {
                InitializationControlsData(groupControl1.Controls);
                insert = true;
            }
            else  //修改
            {
                ID = id;
                insert = false;
                Text = "护理单修改";
                string Select = @"SELECT *   FROM [BNNursingDocsSystem_Develop].[dbo].[t_ClinicalNursing](NOLOCK)  where Id = '" + id + "'";
                DataSet Temp = SqlHelper.ExecuteDataset(Select, CommandType.Text);
                DataTable nursedata = Temp.Tables[0];
                if (nursedata.Rows.Count > 0)
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    StringReader Nurseingdata = new StringReader(nursedata.Rows[0]["data"].ToString());
                    xmlDoc.Load(Nurseingdata);
                    XmlNode nursingrecord = xmlDoc.SelectSingleNode("/NursingRecordDocument");
                    textE_temperature.Text = nursingrecord.ChildNodes[0].InnerText;
                    textE_Pulse.Text = nursingrecord.ChildNodes[1].InnerText;
                    txtE_Breath.Text = nursingrecord.ChildNodes[2].InnerText;
                    textEdit1.Text = nursingrecord.ChildNodes[3].InnerText;
                    txtE_HightBlood.Text = nursingrecord.ChildNodes[4].InnerText;
                    txtE_LowBlood.Text = nursingrecord.ChildNodes[5].InnerText;
                    textE_OxygenSaturation.Text = nursingrecord.ChildNodes[6].InnerText;
                    if (nursingrecord.ChildNodes[7].InnerText == "√") checkBox1.Checked = true;
                    richEditControl1.Text = nursingrecord.ChildNodes[8].InnerText + "#" + nursingrecord.ChildNodes[9].InnerText + "#" + nursingrecord.ChildNodes[10].InnerText;
                    richEditControl2.Text = nursingrecord.ChildNodes[11].InnerText + "#" + nursingrecord.ChildNodes[12].InnerText + "#";
                    richE_ContentInfor.Text = StringHelpers.OutputDecode(nursingrecord.ChildNodes[13].InnerText);
                    dateE_Date.Text = nursedata.Rows[0]["Date"].ToString();
                    timeE_Time.EditValue = DateTimeHelper.HHmmssToHHmm(nursedata.Rows[0]["Time"].ToString());
                    txtsyncSN.Text = nursedata.Rows[0]["syncSN"].ToString();
                    txtSubmituserName.Text = nursedata.Rows[0]["SubmituserName"] + "";
                    chkNewPage.Checked = (nursedata.Rows[0]["IsNewPageFlag"].ToString().Contains("Y"));
                }
            }
        }
        #endregion

        #region 清空
        private void btn_Empty_Click(object sender, EventArgs e)
        {
            InitializationControlsData(groupControl1.Controls);
        }
        #endregion

        #region 初始化控件数据数据
        private void InitializationControlsData(Control.ControlCollection Controls)
        {
            string sign = txtE_Signature.Text;
            foreach (var control in Controls)
            {
                if (control.GetType().Name == "ComboBoxEdit")
                {
                    ((ComboBoxEdit)control).EditValue = "请选择";
                }
                else if (control.GetType().Name == "CheckEdit")
                {
                    ((CheckEdit)control).Checked = false;
                }
                else if (control.GetType().Name == "TextEdit")
                {
                    ((TextEdit)control).Text = "";
                }
                else if (control.GetType().Name == "DateEdit")
                {
                    ((DateEdit)control).DateTime = System.DateTime.Now;
                }
                else if (control.GetType().Name == "TimeEdit")
                {
                    ((TimeEdit)control).EditValue = System.DateTime.Now.ToString("HH:mm");
                }
                else if (control.GetType().Name == "RichEditControl")
                {
                    ((RichEditControl)control).Text = "";
                }
            }
            txtE_Signature.Text = sign;
            richEditControl1.Text = "##";
            richEditControl2.Text = "#";
        }
        #endregion

        #region 输入流体及食物
        private void richEditControl1_DoubleClick(object sender, EventArgs e)
        {

            NursingSummarySelForm3 NSSF = new NursingSummarySelForm3(richEditControl1.Text, patientId);
            NSSF.ShowDialog();
            if (NSSF.DialogResult == DialogResult.OK)
            {
                richEditControl1.Text = NSSF.TempStr;
            }
            else richEditControl1.Text = NSSF.str_ReturnSummary;
        }
        #endregion

        #region 排出流体量
        private void richEditControl2_DoubleClick(object sender, EventArgs e)
        {
            NursingSummarySelForm4 NSSF = new NursingSummarySelForm4(richEditControl2.Text, patientId);
            NSSF.ShowDialog();
            if (NSSF.DialogResult == DialogResult.OK)
            {
                richEditControl2.Text = NSSF.TempStr;
            }
            else richEditControl2.Text = NSSF.str_ReturnSummary;
        }
        #endregion

        #region 病情及护理措施
        private void richE_ContentInfor_DoubleClick(object sender, EventArgs e)
        {
            NursingMeasure xx = new NursingMeasure(richE_ContentInfor.Text, departID);
            xx.ShowDialog();
            if (xx.TTT.Trim() != "")
            {
                richE_ContentInfor.Text = xx.TTT;
            }
        }
        #endregion

        #region 提交
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            string strTime = timeE_Time.Text;
            if (!string.IsNullOrEmpty(strTime))
            {
                string[] arry = strTime.Split(':').ToArray();
                int hour = Convert.ToInt32(arry[0]);
                if (hour > 25)
                {
                    XtraMessageBox.Show("小时数值不正确.");
                    return;
                }
            }
            if (!checkinput()) return;
            string[] temp = Regex.Split(richEditControl1.Text, "#", RegexOptions.IgnoreCase);
            if (temp.Length < 3)
            {
                XtraMessageBox.Show("流入部分未填写，如无流入部分，请填写##");
                return;
            }
            string Intakename = temp[0];
            string Intakevalue = temp[1];
            string Intakeway = temp[2];
            string[] temp2 = Regex.Split(richEditControl2.Text, "#", RegexOptions.IgnoreCase);
            if (temp2.Length < 2)
            {
                XtraMessageBox.Show("流出部分未填写，如无流出部分，请填写#");
                return;
            }
            string Dischargename = temp2[0];
            string Dischargevalue = temp2[1];

            #region xmldata
            string data = @"";
            //string data = @"<?xml version=";
            //data += @"""";
            //data += "1.0";
            //data += @"""";
            //data += "?> ";
            data += "<NursingRecordDocument>  <Temper>";
            data += textE_temperature.Text;
            data += "</Temper>   <Pulse>";
            data += textE_Pulse.Text;
            data += "</Pulse>   <HeartRate>";
            data += txtE_Breath.Text;
            data += "</HeartRate>   <Breath>";
            data += textEdit1.Text;
            data += "</Breath>  <Systolicpressure>";
            data += txtE_HightBlood.Text;
            data += "</Systolicpressure>   <Diastolicpressure>";
            data += txtE_LowBlood.Text;
            data += "</Diastolicpressure>   <Spo2>";
            data += textE_OxygenSaturation.Text;
            data += "</Spo2>   <StandUp>";
            if (checkBox1.Checked == true)
            {
                data += "√";
            }
            data += "</StandUp>  <Intakename>";
            data += Intakename;
            data += "</Intakename>  <Intakevalue>";
            data += Intakevalue;
            data += "</Intakevalue> <Intakediway>";
            data += Intakeway;
            data += "</Intakediway>   <Dischargename> ";
            data += Dischargename;
            data += "</Dischargename>   <Dischargevalue>";
            data += Dischargevalue;
            data += "</Dischargevalue>  <Tendcontent>";
            data += StringHelpers.InputEncode(richE_ContentInfor.Text);
            data += "</Tendcontent>   <NursName>";
            data += txtE_Signature.Text;
            data += "</NursName> "
                + " </NursingRecordDocument>";
            #endregion
            string newpageflag = chkNewPage.Checked ? "Y" : "N";
            SynchroBLL synchro = new SynchroBLL();
            ClinicalNursinguser cn = new ClinicalNursinguser();
            if (insert)  //插入模式
            {
                string rst = System.DateTime.Now.ToString("yyyyMMddHHmmss") + rd.Next(100, 10000).ToString();//用rad生成大于等于1000，小于等于9999的随机数
                string TempInsert = @"insert into t_ClinicalNursing  ([PatientId]  ,[VISIT_ID] ,[PatientName],[DepId] ,[DepName] ,[AreaId] ,[AreaName] ,[Date],[Time],[data] ,[NursName]
                                             ,[Submittime] ,[SubmituserId] ,[SubmituserName] ,[Updatetime] ,[UpdateuserId] ,[UpdateuserName],[SYNCSN],[IsNewPageFlag])
                                         VALUES(
                                         '" + lab_PatientID.Text + @"','"
                                              + lab_VisitID.Text + @"',
                                          '" + lab_Name.Text + @"',
                                          '" + departID + @"',
                                          '" + departName + @"',
                                          '" + departID + @"',
                                          '" + departName + @"',  
                                          '" + dateE_Date.Text + @"',
                                         '" + DateTimeTran.TimeFillZero(timeE_Time.Text) + @"',
                                          '" + data + @"',
                                         '" + txtE_Signature.Text + @"',
                                          '" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + @"',
                                         '" + nurseID + @"',
                                         '" + txtE_Signature.Text + @"',
                                         '" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + @"',
                                         '" + nurseID + @"',
                                         '" + txtE_Signature.Text + @"', 
                                         '" + rst + @"' ,
                                         '" + newpageflag + @"'                        
                                         )";
                int num = SqlHelper.ExecuteNonQuery(CommandType.Text, TempInsert);
                if (num > 0)
                {
                    XtraMessageBox.Show("新增成功");
                    Close();

                    #region 上传海泰
                    if (Base.ESSwitchHT == "1")
                    {
                        loading.ShowWaitForm();
                        cn.PatientId = lab_PatientID.Text;
                        cn.PatientName = lab_Name.Text;
                        cn.DepId = departID;
                        cn.DepName = departName;
                        cn.AreaId = departID;
                        cn.AreaName = departName;
                        cn.data = data;
                        cn.Date = dateE_Date.Text;
                        cn.Time = timeE_Time.Text;
                        cn.NursName = txtE_Signature.Text;
                        cn.VisitId = Convert.ToInt32(lab_VisitID.Text);
                        cn.UpdateuserId = nurseID;
                        cn.UpdateuserName = txtE_Signature.Text;
                        cn.syncSN = rst;
                        synchro.clinicalNursingInfoAsyncToEMRDelegateMethod(cn, "002", "1");
                        loading.CloseWaitForm();
                    }
                    #endregion
                }
                else
                {
                    XtraMessageBox.Show("新增失败");
                }
            }
            else //修改模式
            {
                string update = @"update t_ClinicalNursing set 
                  [Date] = '" + dateE_Date.Text + @"'
                  ,[Time] = '" + DateTimeTran.TimeFillZero(timeE_Time.Text) + @"'
                 ,[Data] = '" + data + @"'
               
                ,[Updatetime] = '" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + @"'
                ,[UpdateuserId] = '" + nurseID + @"'
                ,[UpdateuserName] = '" + txtE_Signature.Text + @"'
                ,[IsNewPageFlag] = '" + newpageflag + @"'
                  WHERE Id='" + ID + "'";
                int num = SqlHelper.ExecuteNonQuery(CommandType.Text, update);
                if (num > 0)
                {
                    XtraMessageBox.Show("修改成功");
                    Close();

                    #region 上传海泰
                    if (Base.ESSwitchHT == "1")
                    {
                        loading.ShowWaitForm();
                        cn.PatientId = lab_PatientID.Text;
                        cn.PatientName = lab_Name.Text;
                        cn.DepId = departID;
                        cn.DepName = departName;
                        cn.AreaId = departID;
                        cn.AreaName = departName;
                        cn.data = data;
                        cn.Date = dateE_Date.Text;
                        cn.Time = timeE_Time.Text;
                        cn.Updatetime = DateTime.Now;
                        cn.UpdateuserId = nurseID;
                        cn.UpdateuserName = txtSubmituserName.Text;
                        cn.VisitId = Convert.ToInt32(lab_VisitID.Text);
                        cn.NursName = txtSubmituserName.Text;//特殊要求：默认取第一次新增护理单护士名字，更新不用修改护士名字(需求不清晰还未修改)
                        cn.syncSN = txtsyncSN.Text;
                        synchro.clinicalNursingInfoAsyncToEMRDelegateMethod(cn, "002", "2");
                        loading.CloseWaitForm();
                    }
                    #endregion
                }
                else
                {
                    XtraMessageBox.Show("修改失败");
                }
            }
            //string signXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><huanzhehao name=\"患者号\">" + lab_PatientID.Text + "</huanzhehao><xingming name=\"姓名\">" + lab_Name.Text + "</xingming>"
            //    + "<zhuyuancishu name=\"住院次数\">" + lab_VisitID.Text + "</zhuyuancishu><riqi name=\"日期\">" + dateE_Date.Text + "</riqi><shijian Name=\"时间\">" + timeE_Time.Text + "</shijian>"
            //    + "<tiwen Name=\"体温\">" + textE_temperature.Text + "</tiwen><maibo Name=\"脉搏\">" + textE_Pulse.Text + "</maibo><xinlv Name=\"心率\">" + txtE_Breath.Text + "</xinlv>"
            //    + "<huxi Name=\"呼吸\">" + textEdit1.Text + "</huxi><xueya Name=\"血压\">" + txtE_HightBlood.Text + "</xueya><xueya Name=\"血压\">" + txtE_LowBlood.Text + "</xueya>"
            //    + "<xueyangbaohedu Name=\"血氧饱和度\">" + textE_OxygenSaturation.Text + "</xueyangbaohedu><shifoufanshen Name=\"是否翻身\">" + checkBox1.Text + "</shifoufanshen>"
            //    + "<shuruliutijishiwu Name=\"输入流涕及食物\">" + richEditControl1.Text + "</shuruliutijishiwu><paichuliutiliang Name=\"排除流体量\">" + richEditControl2.Text + "</paichuliutiliang>"
            //    + "<bingqingjihulicuoshi Name=\"病情及护理措施\">" + richE_ContentInfor.Text + "</bingqingjihulicuoshi><qianming Name=\"签名\">" + txtE_Signature.Text + "</qianming>	";
            //TODO:电签接口提交
        }
        //验证
        private bool checkinput()
        {
            if (textE_temperature.Text.Length > 0)
            {
                if (Convert.ToDouble(textE_temperature.Text) < 32 || Convert.ToDouble(textE_temperature.Text) > 43)
                {
                    XtraMessageBox.Show("体温输入错误");
                    return false;
                }
            }
            if (textE_Pulse.Text.Length > 0)
            {
                if (Convert.ToDouble(textE_Pulse.Text) < 0 || Convert.ToDouble(textE_Pulse.Text) > 300)
                {
                    XtraMessageBox.Show("脉搏输入错误");
                    return false;
                }
            }
            if (txtE_Breath.Text.Length > 0)
            {
                if (Convert.ToDouble(txtE_Breath.Text) < 0 || Convert.ToDouble(txtE_Breath.Text) > 300)
                {
                    XtraMessageBox.Show("心率输入错误");
                    return false;
                }
            }
            if (textEdit1.Text.Length > 0)
            {
                if (Convert.ToDouble(textEdit1.Text) < 0 || Convert.ToDouble(textEdit1.Text) > 150)
                {
                    XtraMessageBox.Show("呼吸输入错误");
                    return false;
                }
            }
            if (txtE_HightBlood.Text.Length > 0)
            {
                //取消判断 值有可能为 不在  来自体温导入
                //if (Convert.ToDouble(txtE_HightBlood.Text) < 0 || Convert.ToDouble(txtE_HightBlood.Text) > 300)
                //{
                //    XtraMessageBox.Show("高压输入错误");
                //    return false;
                //}
            }
            if (txtE_LowBlood.Text.Length > 0)
            {
                //取消判断 值有可能为 不在  来自体温导入
                //if (Convert.ToDouble(txtE_LowBlood.Text) < 0 || Convert.ToDouble(txtE_LowBlood.Text) > 300)
                //{
                //    XtraMessageBox.Show("低压输入错误");
                //    return false;
                //}
            }
            if (textE_OxygenSaturation.Text.Length > 0)
            {
                if (Convert.ToDouble(textE_OxygenSaturation.Text) < 0 || Convert.ToDouble(textE_OxygenSaturation.Text) > 100)
                {
                    XtraMessageBox.Show("血氧饱和度输入错误");
                    return false;
                }
            }
            return true;
        }
        #endregion

        #region 体温导入
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            TemperatureIn x = new TemperatureIn(lab_PatientID.Text, lab_VisitID.Text);
            x.ShowDialog();
            if (x.DialogResult == DialogResult.Yes)
            {
                textE_temperature.Text = x.tiwen;
                textE_Pulse.Text = x.maibo;
                txtE_Breath.Text = x.xinlv;
                textEdit1.Text = x.huxi;
                txtE_HightBlood.Text = x.xueya1;
                txtE_LowBlood.Text = x.xueya2;
            }
        }
        #endregion

        #region 查看医嘱
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            PatientOrders xx = new PatientOrders(lab_PatientID.Text, lab_VisitID.Text, departID);
            xx.ShowDialog();
            if (xx.DialogResult == DialogResult.Yes)
            {
                string[] temp = Regex.Split(richEditControl1.Text, "#", RegexOptions.IgnoreCase);
                string[] tempname = Regex.Split(temp[0], ",", RegexOptions.IgnoreCase);
                string[] tempnum = Regex.Split(temp[1], ",", RegexOptions.IgnoreCase);
                string[] tempway = Regex.Split(temp[2], ",", RegexOptions.IgnoreCase);
                string TempStr = "";
                for (int i = 0; i < tempname.Length; i++)
                {
                    TempStr += tempname[i].ToString();
                    if (tempname[i].ToString().Trim().Length != 0)
                    {
                        TempStr += ",";
                    }
                }
                for (int i = 0; i < xx.NameList.Count; i++)
                {
                    TempStr += xx.NameList[i].ToString();
                    TempStr += ",";
                }
                TempStr = TempStr.Substring(0, TempStr.Length - 1);
                TempStr += "#";
                for (int i = 0; i < tempnum.Length; i++)
                {
                    TempStr += tempnum[i].ToString();
                    if (tempnum[i].ToString().Trim().Length != 0)
                    {
                        TempStr += ",";
                    }
                }
                for (int i = 0; i < xx.NumList.Count; i++)
                {
                    TempStr += xx.NumList[i].ToString();
                    TempStr += ",";
                }
                TempStr = TempStr.Substring(0, TempStr.Length - 1);
                TempStr += "#";
                for (int i = 0; i < tempway.Length; i++)
                {
                    TempStr += tempway[i].ToString();
                    if (tempway[i].ToString().Trim().Length != 0)
                    {
                        TempStr += ",";
                    }
                }
                for (int i = 0; i < xx.WayList.Count; i++)
                {
                    TempStr += xx.WayList[i].ToString();
                    TempStr += ",";
                }
                TempStr = TempStr.Substring(0, TempStr.Length - 1);
                richEditControl1.Text = TempStr;
            }
        }
        #endregion

        #region 按回车键定位到下一位置
        private void timeE_Time_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)//判断回车键
            {
                textE_temperature.Focus();

            }
        }
        private void textE_temperature_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)//判断回车键
            {
                textE_Pulse.Focus();
            }
        }

        private void textE_Pulse_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)//判断回车键
            {
                txtE_Breath.Focus();
            }
        }

        private void txtE_Breath_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)//判断回车键
            {
                textEdit1.Focus();
            }
        }

        private void textEdit1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)//判断回车键
            {
                txtE_HightBlood.Focus();
            }
        }

        private void txtE_HightBlood_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)//判断回车键
            {
                txtE_LowBlood.Focus();
            }
        }

        private void txtE_LowBlood_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)//判断回车键
            {
                textE_OxygenSaturation.Focus();
            }
        }

        private void textE_OxygenSaturation_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)//判断回车键
            {
                checkBox1.Focus();
            }
        }

        private void checkBox1_KeyDown(object sender, KeyEventArgs e)
        {
            richEditControl1.Focus();
        }

        private void richEditControl1_KeyDown(object sender, KeyEventArgs e)
        {
            richEditControl2.Focus();
        }

        private void txtE_Signature_KeyDown(object sender, KeyEventArgs e)
        {
            btn_Submit.Focus();
        }
        #endregion

        private void BtnMyTemplate_Click(object sender, EventArgs e)
        {
            string[] UserParam = { nurseID };
            NoticeMain noticefrm = new NoticeMain(UserParam);
            noticefrm.WindowState = FormWindowState.Normal;
            noticefrm.Show();
        }
    }
}
public abstract class StringHelpers
{
    private static string[][] shiftString = new string[][] {
            new string[2] {"'", "$1"},
            new string[2] {"(", "$2"},
            new string[2] {")", "$3"},
            new string[2] {"<", "$4"},
            new string[2] {">", "$5"},
            new string[2] {"=", "$6"},
            new string[2] {"+", "$7"},
            new string[2] {"-", "$8"},
            new string[2] {"&", "$9"}
        };

    /// <summary>
    /// 输入字符串编码
    /// <param name="input">待编码的字符串</param>
    /// </summary>
    public static string InputEncode(string input)
    {
        if (String.IsNullOrEmpty(input)) return String.Empty;
        for (int i = 0; i < shiftString.Length; i++)
        {
            input = input.Replace(shiftString[i][0], shiftString[i][1]);
        }
        return input;
    }

    /// <summary>
    /// 输入字符串解码
    /// <param name="input">待解码的字符串</param>
    /// </summary>
    public static string OutputDecode(string input)
    {
        if (String.IsNullOrEmpty(input)) return String.Empty;
        for (int i = 0; i < shiftString.Length; i++)
        {
            input = input.Replace(shiftString[i][1], shiftString[i][0]);
        }
        return input;
    }
}